﻿<cfsilent>
	<cfscript>
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");

		sql = "SELECT a.institute_id,a.institute_name
				FROM t_institute a 
				WHERE a.institute_id = :insId ";
		queryObj = new Query( datasource=application.dnsSlave ); 
		queryObj.addParam( name="insId", value=event.getArg("DepID"), cfsqltype="cf_sql_varchar" );
		rs_department = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT 
						count(*) num, 
						b.cat_name,
						b.cat_id
				FROM t_course a 
					 INNER JOIN t_course_catalog b ON b.cat_id = a.cat_id  
				WHERE 
					a.institute_id = :depId 
					AND 
					a.abandon = '0' 
				GROUP BY b.cat_name, b.cat_id
				ORDER BY b.cat_id ";
		queryObj = new Query( datasource=application.dnsSlave ); 
		queryObj.addParam( name="depId", value=rs_department.institute_id, cfsqltype="cf_sql_varchar" );
		rs_cat = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT a.cat_id,a.cat_name  
				FROM t_course_catalog a  
				ORDER BY a.cat_id";
		queryObj = new Query( datasource=application.dnsSlave ); 
		rs_catalog = queryObj.execute( sql=sql ).getResult();
		
		
		sql = "SELECT 
					a.cid, a.course_name, a.course_code, 
					a.course_credit, 
					a.period, a.period_theory, a.period_practice, a.period_computer, a.period_week, 
					a.mark_mode
				FROM t_course a  
				WHERE 
					a.institute_id = :depId 
					AND 
					a.abandon = '1' 
					ORDER BY a.course_name";
		queryObj = new Query( datasource=application.dnsSlave ); 
		queryObj.addParam( name="depId", value=rs_department.institute_id, cfsqltype="cf_sql_varchar" );
		rs_abandon = queryObj.execute( sql=sql ).getResult();
		
		event.setArg("pageTitle", "教学运行基础数据 -课程库维护 - 任课单位概况 - " & rs_department.institute_name);

		targetArgs = structNew();
		structInsert(targetArgs, "DepID", rs_department.institute_id, true);

		currentTab = event.getArg("Cat", "00");

		if ( rs_cat.recordCount gte 1 ) {
			currentTab = event.getArg("Cat", rs_cat["cat_id"][1]);
		}

		if ( rs_cat.recordCount eq 0 ) {
			currentTab = "labCreate";
		}
		
		/* 搜索课程 */
		keyword = event.getArg("Keywords");
		
		//searchArray = [];
		rs_search = queryNew("cid");
		
		if ( len(keyword) ) {
		
			sql = "SELECT 
						a.cid, a.course_name, 
						a.course_code, a.course_credit, 
						a.period, a.period_theory, 
						a.period_practice, a.period_computer,
						a.period_week, a.mark_mode, 
						a.institute_id, a.abandon 
					FROM t_course a  
					WHERE 
						a.institute_id = :depId 
						AND
						(
							a.course_code LIKE :condition 
							OR 
							a.course_name LIKE :condition 
						)
					ORDER BY a.course_name  ";	
			queryObj = new Query( datasource=application.dnsSlave,maxRows=20  ); 
			queryObj.addParam( name="condition", value=keyword&"%" , cfsqltype="cf_sql_varchar" );
			queryObj.addParam( name="depId", value=rs_department.institute_id, cfsqltype="cf_sql_varchar" );
			rs_search = queryObj.execute( sql=sql ).getResult();
			currentTab = "labSearch";
		}

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('programCourse')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">课程基础信息</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i><cfoutput>#rs_department.institute_name#</cfoutput>课程开设情况
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
                        <cfloop query="rs_cat" >
							<span <cfif currentTab eq rs_cat.cat_id>class="active"</cfif> id="labCourseCat<cfoutput>#rs_cat.cat_id#</cfoutput>" tabTarget="CourseCat<cfoutput>#rs_cat.cat_id#</cfoutput>"><cfoutput>#rs_cat.cat_name#</cfoutput></span>
						</cfloop>
						<cfif rs_abandon.recordCount>
							<span <cfif currentTab eq "labAbandon">class="active"</cfif> id="labAbandon" tabTarget="Abandon">已停开课程</span>
						</cfif>
						<span <cfif currentTab eq "labCreate">class="active"</cfif> id="labCreate" tabTarget="Create">设置新课程</span>
						<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">搜索</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
                <cfloop query="rs_cat" >
					
					<cfset sql = "SELECT 
										a.cid, a.course_name, 
										a.course_code, a.course_credit, 
										a.period, a.period_theory, 
										a.period_practice, a.period_computer,
										a.period_week, a.mark_mode,b.prop_name 
									FROM t_course a  
										INNER JOIN t_course_prop b ON b.prop_id = a.prop_id 
									WHERE 
										a.institute_id = :depId 
										AND
										a.cat_id = :catId 
										AND
										a.abandon = '0' 
									ORDER BY a.course_name  "/>
                    <cfset queryObj = new Query( datasource=application.dnsSlave )/>
                    <cfset queryObj.addParam( name="depId", value=rs_department.institute_id, cfsqltype="cf_sql_varchar" )/>
                    <cfset queryObj.addParam( name="catId", value=rs_cat.cat_id, cfsqltype="cf_sql_char" )/>
                    <cfset rs_course = queryObj.execute( sql=sql ).getResult()/>
					<div id="CourseCat<cfoutput>#rs_cat.cat_id#</cfoutput>" class="tabContent">

						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<td width="80">课程号</td>
									<td>课程</td>
                                             <td width="50" align="center">类别</td>
									<td width="24" align="center">学分</td>
									<td width="50" align="center">计分</td>
									<td width="36" align="center">总学时</td>
									<td width="24" align="center">理论</td>
									<td width="24" align="center">实践</td>
									<td width="24" align="center">上机</td>
									<td width="36" align="center">周学时</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_course" >
									<cfset row ++ />
									<cfset structInsert(targetArgs, "CID", rs_course.cid, true) />
									<tr class="editRows <cfif event.getArg('CID') eq rs_course.cid> lastEdited</cfif>">
										<td><span class="index"><cfoutput>#row#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#rs_course.course_code#</cfoutput></span></td>
										<td><cfoutput>#rs_course.course_name#</cfoutput></td>
                                                  <td align="center"><cfoutput>#rs_course.prop_name#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#numberFormat(rs_course.course_credit, "0.0")#</cfoutput></span></td>
										<td align="center"><cfoutput>#dictAdvice.getMarkModeName(rs_course.mark_mode)#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_course.period#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_course.period_theory#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_course.period_practice#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_course.period_computer#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#numberFormat(rs_course.period_week,"__")#</cfoutput></span></td>
										<td><a class="edit" href="<cfoutput>#buildURL('courseDetail', targetArgs)#</cfoutput>"></a></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
					
					</div>
				</cfloop>
				
				<div id="Create" class="tabContent">
					
					<cfif event.getArg("courseExistsID") neq "">
						
						<div class="systemNotice">
							<h3><span class="img icon16x16 info"></span>《<cfoutput>#event.getArg('CourseName')#</cfoutput>》在开课学院有重复记录</h3>
							<p>您当前要求录入的课程《<cfoutput>#event.getArg('CourseName')#</cfoutput>》在课程库的存在已有记录. 任课单位在课程设置时, 必须保证课程名称唯一性.</p>
						</div>
						
					</cfif>
					
					<form id="formCreate" onSubmit="javascript:return processVerfiyForm('formCreate');" class="formWrapper " method="post" action="<cfoutput>#buildURL('courseCreateDo')#</cfoutput>">
						
						<input name="InstituteID" id="InstituteID" type="hidden" value="<cfoutput>#rs_department.institute_id#</cfoutput>" />
						
						<div class="label">
							<span class="req">*</span><b>课程</b>
							<input name="CourseName" id="CourseName" type="text" class="typeTextShort" verification="required" maxlength="30" value="<cfoutput>#event.getArg('CourseName')#</cfoutput>" />
						</div>
						
						<div class="label">
							<span class="req">*</span><b>学分</b>
							<input name="Credit" id="Credit" type="text" class="typeTinyInt" verification="double" maxlength="4" value="<cfoutput>#event.getArg('Credit', '2.0')#</cfoutput>" />
						</div>
						
						<div class="label">
							<span class="req">*</span><b>学时分布</b>
							理论学时<input name="PeriodTheory" id="PeriodTheory" type="text" class="typeTinyInt" verification="integer" maxlength="4" value="<cfoutput>#event.getArg('PeriodTheory', '0')#</cfoutput>" />
							实践学时<input name="PeriodPractice" id="PeriodPractice" type="text" class="typeTinyInt" verification="integer" maxlength="4" value="<cfoutput>#event.getArg('PeriodPractice', '0')#</cfoutput>" />
							实验学时<input name="PeriodComputer" id="PeriodComputer" type="text" class="typeTinyInt" verification="integer" maxlength="4" value="<cfoutput>#event.getArg('PeriodComputer', '0')#</cfoutput>" />
						</div>
						
						<div class="label">
							<span class="req">*</span><b>课程号</b>
							<input name="CourseCode" id="CourseCode" type="text" class="typeCode" verification="required" maxlength="20" value="<cfoutput>#event.getArg('CourseCode')#</cfoutput>" />
							<p class="notice">如果学校对于课程有自己的编码规范, 您可以在这里手工指定现有课程的编码</p>
						</div>

						<div class="label">
							<b>计分模式</b>
							<select name="MarkMode">
								<option <cfif event.getArg('MarkMode') eq '0'>selected="selected"</cfif> value="0">百分制</option>
								<!---<option <cfif event.getArg('MarkMode') eq '2'>selected="selected"</cfif> value="2">两级制（通过、不通过）</option>--->
								<option <cfif event.getArg('MarkMode') eq '4'>selected="selected"</cfif> value="4">五级制（优秀、良好、中、及格、不及格）</option>
							</select>
						</div>
						
						<hr/>
						
						<div class="label">
							<b>安排补考</b>
							<input name="ResitPolicy" type="radio" class="typeRadio" value="1" <cfif event.getArg('ResitPolicy', '1') eq '1'>checked="checked"</cfif> />是
							<input name="ResitPolicy" type="radio" class="typeRadio" value="0" <cfif event.getArg('ResitPolicy') eq '0'>checked="checked"</cfif>/>否
						</div>
						
						<div class="label">
							<b>已停止开课</b>
							<input name="Abandon" type="radio" class="typeRadio" value="1" <cfif event.getArg('Abandon') eq '1'>checked="checked"</cfif> />是
							<input name="Abandon" type="radio" class="typeRadio" value="0" <cfif event.getArg('Abandon', '0') eq '0'>checked="checked"</cfif>/>否
						</div>
                              
                               <div class="label">
							<b>课程类别</b>
							<input name="courseProp" type="radio" class="typeRadio" value="1" checked="checked" />必修
							<input name="courseProp" type="radio" class="typeRadio" value="2"/>限选
						</div>
						
						<hr/>
						
						<div class="label">
							<b>排课周学时</b>
                                   <select name="PeriodPerWeek">
								<option <cfif event.getArg('PeriodPerWeek') eq 0>selected="selected"</cfif> value="0">不排课</option>
                                        <option <cfif event.getArg('PeriodPerWeek') eq 1>selected="selected"</cfif> value="1">每周一次课，每次1小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq 2>selected="selected"</cfif> value="2">每周一次课, 安排2小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq 3>selected="selected"</cfif> value="3">每周一次课, 安排3小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq 4>selected="selected"</cfif> value="4">每周两次课, 每次2小节 或 每周一次课, 连续4小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq 5>selected="selected"</cfif> value="5">每周两次课, 一次2小节,一次3小节 或 每周一次课, 连续5小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq 6>selected="selected"</cfif> value="6">每周三次课, 每次2小节 或 每周两次课, 每次3小节 或 一次4小节, 一次3小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq 8>selected="selected"</cfif> value="8">每周四次课, 每次2小节 或 每周三次课, 两次3小节, 一次2小节 或 每周两次课,每次4小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq 10>selected="selected"</cfif> value="10">每周五次课, 每次2小节 或 每周四次课, 两次3小节, 两次2小节</option>
                                        <option <cfif event.getArg('PeriodPerWeek') eq 12>selected="selected"</cfif> value="12">每周六次课, 每次2小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq 16>selected="selected"</cfif> value="16">每周四次课，每次4小节</option>
							</select>
							
						</div>
						
						<div class="label">
							<b>课程类别</b>
							<select name="CatID">
                                <cfloop query="rs_catalog" >
									<option <cfif event.getArg('Cat') eq rs_catalog.cat_id>selected="selected"</cfif> value="<cfoutput>#rs_catalog.cat_id#</cfoutput>"><cfoutput>#rs_catalog.cat_name#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						
						<hr/>
						
						<div class="label">
							<b>英文名称</b>
							<input name="CourseEnglish" id="CourseEnglish" type="text" class="typeText typeEnglish" maxlength="180" value="<cfoutput>#event.getArg('CourseEnglish')#</cfoutput>" />
						</div>
						
						<div class="label">
							<b>课程介绍</b>
							<textarea name="Intro" id="Intro"><cfoutput>#event.getArg('Intro')#</cfoutput></textarea>
						</div>
						
						<div class="label">
							<b>参考书</b>
							<textarea name="ReferenceBooks" id="ReferenceBooks"><cfoutput>#event.getArg('ReferenceBooks')#</cfoutput></textarea>
						</div>
						
						<hr/>
						
						<div class="lable">
							<input class="button" type="submit" value="提交" />
							<input class="button" type="reset" value="重设表格" />
						</div>
						
					</form>

				</div>
				
				<div id="Abandon" class="tabContent">
					
					<cfset row = 0 />
					<table class="UIEditable">
						<thead>
							<tr>
								<td width="18"></td>
								<td width="80">课程号</td>
								<td>课程</td>
								<td width="24" align="center">学分</td>
								<td width="50" align="center">计分</td>
								<td width="36" align="center">总学时</td>
								<td width="24" align="center">理论</td>
								<td width="24" align="center">实践</td>
								<td width="24" align="center">上机</td>
								<td width="36" align="center">周学时</td>
								<td width="18"></td>
							</tr>
						</thead>
						<tbody>
                            <cfloop query="rs_abandon" >
								<cfset row ++ />
								<cfset structInsert(targetArgs, "CID", rs_abandon.cid, true) />
								<tr class="editRows <cfif event.getArg('CID') eq rs_abandon.cid> lastEdited</cfif>">
									<td><span class="index"><cfoutput>#row#</cfoutput></span></td>
									<td><span class="numeric"><cfoutput>#rs_abandon.course_code#</cfoutput></span></td>
									<td><cfoutput>#rs_abandon.course_name#</cfoutput></td>
									<td align="center"><span class="numeric"><cfoutput>#numberFormat(rs_abandon.course_credit, "0.0")#</cfoutput></span></td>
									<td align="center"><cfoutput>#dictAdvice.getMarkModeName(rs_abandon.mark_mode)#</cfoutput></td>
									<td align="center"><span class="numeric"><cfoutput>#rs_abandon.period#</cfoutput></span></td>
									<td align="center"><span class="numeric"><cfoutput>#rs_abandon.period_theory#</cfoutput></span></td>
									<td align="center"><span class="numeric"><cfoutput>#rs_abandon.period_practice#</cfoutput></span></td>
									<td align="center"><span class="numeric"><cfoutput>#rs_abandon.period_computer#</cfoutput></span></td>
									<td align="center"><span class="numeric"><cfoutput>#numberFormat(rs_abandon.period_week,"__")#</cfoutput></span></td>
									<td><a class="edit" href="<cfoutput>#buildURL('courseDetail', targetArgs)#</cfoutput>"></a></td>
								</tr>
							</cfloop>
						</tbody>
					</table>
					
				</div>
				
				<div id="Search" class="tabContent">
					
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('courseByDepartment')#</cfoutput>">
						<input type="hidden" name="TabID" value="labSearch" />
						<input type="hidden" name="DepID" value="<cfoutput>#rs_department.institute_id#</cfoutput>" />
						
						<div class="label">
							<b>课程或课程号</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					
					<cfif rs_search.recordCount>
						
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<td width="80">课程号</td>
									<td>课程</td>
									<td width="24" align="center">学分</td>
									<td width="50" align="center">计分</td>
									<td width="36" align="center">总学时</td>
									<td width="24" align="center">理论</td>
									<td width="24" align="center">实践</td>
									<td width="24" align="center">上机</td>
									<td width="36" align="center">周学时</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_search" >
									<cfset row ++ />
									<cfset structInsert(targetArgs, "CID", rs_search.cid, true) />
									<cfset structInsert(targetArgs, "DepID", rs_search.institute_id, true) />
									<tr class="editRows <cfif rs_search.abandon eq "1"> cancelRow</cfif>">
										<td><span class="index"><cfoutput>#row#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#rs_search.course_code#</cfoutput></span></td>
										<td><cfoutput>#rs_search.course_name#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#numberFormat(rs_search.course_credit, "0.0")#</cfoutput></span></td>
										<td align="center"><cfoutput>#dictAdvice.getMarkModeName(rs_search.mark_mode)#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_search.period#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_search.period_theory#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_search.period_practice#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_search.period_computer#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#numberFormat(rs_search.period_week,"__")#</cfoutput></span></td>
										<td><a class="edit" href="<cfoutput>#buildURL('courseDetail', targetArgs)#</cfoutput>"></a></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
						
					</cfif>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>


